/*
 * Copyright 2019-2021 shoprh.com. All rights reserved.
 * Support: http://www.shoprh.com
 * License: http://www.shoprh.com/license
 */
package com.shoprh.shop.controller;

import com.shoprh.shop.domain.AdPosition;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.shoprh.common.core.domain.R;
import com.shoprh.common.core.controller.BaseController;
import com.shoprh.shop.service.IAdPositionService;
import org.wf.jwtp.annotation.RequiresPermissions;

/**
 * Controller - 广告位
 *
 * @author 若狐 Team
 * @version 1.0
 */
@RestController
@RequestMapping("admin/adPosition")
public class AdPositionController extends BaseController {

    @Autowired
    private IAdPositionService adPositionService;

    /**
     * 查询广告位
     */
    @GetMapping("get/{id}")
    public AdPosition get(@PathVariable("id") Long id) {
        return adPositionService.selectAdPositionById(id);
    }

    /**
     * 查询广告位列表
     */
    @RequiresPermissions("admin:adPosition:list")
    @GetMapping("list")
    public R list(AdPosition adPosition) {
        startPage();
        return result(adPositionService.selectAdPositionList(adPosition));
    }


    /**
     * 新增保存广告位
     */
    @RequiresPermissions("admin:adPosition:add")
    @PostMapping("save")
    public R addSave(@RequestBody AdPosition adPosition) {
        return toAjax(adPositionService.insertAdPosition(adPosition));
    }

    /**
     * 修改保存广告位
     */
    @RequiresPermissions("admin:adPosition:edit")
    @PostMapping("update")
    public R editSave(@RequestBody AdPosition adPosition) {
        return toAjax(adPositionService.updateAdPosition(adPosition));
    }

    /**
     * 删除广告位
     */
    @RequiresPermissions("admin:adPosition:remove")
    @PostMapping("remove")
    public R remove(String ids) {
        return toAjax(adPositionService.deleteAdPositionByIds(ids));
    }

}
